 package com.mark.flutterhybridandroid;

import android.content.Intent;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;

import io.flutter.facade.Flutter;

import static com.mark.flutterhybridandroid.FlutterAppActivity.INIT_PARAMS;

 public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText paramInput = findViewById(R.id.paramInout);
        findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String inputParams = paramInput.getText().toString().trim();
                startActivity(new Intent(MainActivity.this,FlutterAppActivity.class)
                .putExtra(INIT_PARAMS,inputParams));
            }
        });


        /**
         * Flutter混合开发
         */
       /* findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //一、Flutter.createFragment
                //开启事物
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                //执行的操作
                transaction.replace(R.id.fl_content,
                        Flutter.createFragment("{name:'devio',dataList:['aa','bb','cc'}"));
                //提交事物
                transaction.commit();

                //二、Flutter.createView
               *//* View flutterView = Flutter.createView(MainActivity.this,
                        getLifecycle(),"Route1");
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(600,800);
                layoutParams.leftMargin = 100;
                layoutParams.topMargin = 200;
                addContentView(flutterView,layoutParams);*//*
            }
        });*/
    }
}
